﻿<template>
  <div>
      <h3>当前求和:{{sum}}</h3>
      <h4>当前求和的值放大10倍:{{$store.getters.bigSum}}</h4>
      <h4>我在{{school}},学习{{subject}}</h4>
      <select name="" id="" v-model.number="n">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
      </select>
      <button @click="add(n)">+</button>
      <button @click="jf(n)">-</button>
      <button @click="jadd(n)">当前求和为奇数再加</button>
      <button @click="delayAdd(n)">等一等再加</button>
  </div>
</template>

<script>
    import {mapState,mapGetters,mapMutations,mapActions} from 'vuex'
    export default {
        name: 'Add',
        components:{},
        data() {
            return {
                n:1,
            }
        },
        methods: {
            /* add(){
                this.$store.commit('JIA',this.n)
            },
            jf(){
                this.$store.commit('JIAN',this.n)
            }, */

            ...mapMutations({add:'JIA',jf:'JIAN'}),

            /************************** */
            /* jAdd(){
                this.$store.dispatch('jadd',this.n)
            },
            delayAdd(){
                this.$store.dispatch('delayAdd',this.n)
            } */
            ...mapActions(['jadd','delayAdd'])
        },
        mounted(){ 
            console.log('Add',this.$store)
            // const x = mapState({sum:'sum',school:'school',subject:'subject'})
            // console.log(x)
        },
        computed:{
            
            ...mapState(['sum','school','subject']),

            ...mapGetters(['bigSum']),

        },
    }
</script>

<style scoped>

</style>